package com.lifa.controller;

import com.lifa.dao.HuiYuanDao;
import com.lifa.entity.Huiyuan;
import com.lifa.service.HuiYuanService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/huiyuan")
@Scope("prototype")
public class HuiYuanController {

    @Autowired
    private HuiYuanService huiYuanService;

    @Autowired
    private HuiYuanDao huiYuanDao;

    /**
     * 查询
     * @return
     */
    @RequestMapping("/chax")
    @ResponseBody
    public List<Huiyuan> chax(){
        return huiYuanService.chax();
    }

    /**
     *模糊查询
     */
    @RequestMapping("/fenyemohchax1")
    @ResponseBody
    public Map<String,Object> fenyemohchax1(String username, int offset, int limit){
        Map<String,Object> map=new HashMap<String, Object>();
        map.put("rows",huiYuanService.fenyemohchax1(username,offset,limit));
        map.put("total",huiYuanService.mohchax1(username));
        return map;
    }

    @RequestMapping("/tianjia1")
    @ResponseBody
    public int tianjia1(Huiyuan huiyuan){
        System.out.println(huiyuan.getHuiyuan_Kahao());
        return huiYuanService.tianjia1(huiyuan);
    }

    @RequestMapping("/sc1")
    @ResponseBody
    public int sc1(int huiyuan_Id){
        return huiYuanService.sc1(huiyuan_Id);
    }

    @RequestMapping("/xgai1")
    @ResponseBody
    public int xgai1(Huiyuan huiyuan){
        return huiYuanService.xgai(huiyuan);
    }

    @RequestMapping("/xgaiid1")
    @ResponseBody
    public Huiyuan xgaiid1(int huiyuan_Id){
        return huiYuanService.xgaiid(huiyuan_Id);
    }

    @RequestMapping("/jifenxgai1")
    @ResponseBody
    public int jifenxgai1(Huiyuan huiyuan){
        return huiYuanService.jifenxgai1 (huiyuan);
    }
    @RequestMapping("/xiugaijine")
    @ResponseBody
    public int xiugaijine(int huiyuan_Id,int huiyuan_Jifen){return huiYuanDao.xiugaijine(huiyuan_Jifen,huiyuan_Id);}
}
